package com.zjs.jsp.fdservice.service.mongodb;

import com.zjs.jsp.domain.jsp.Jsp_ExceptionOrder;
import com.zjs.jsp.domain.jsp.Jsp_Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 李文
 * @create 2017-09-01 20:10
 **/
@Component
public class ExceptionOrderExpand
{
    private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionOrderExpand.class);

    @Autowired
    private ExceptionOrderRepository exceptionOrderRepository;

    public void save(Jsp_ExceptionOrder o) {
        try {
            exceptionOrderRepository.save(o);
        } catch (Exception e) {
            LOGGER.error(o.getUuid() + "  保存异常数据出错  异常原因 ：" + o.getExMessage(), e);
        }
    }

    public void saveEx(Jsp_Order jspOrder, Exception e, String s, int state, String exMessage) {
        LOGGER.error(jspOrder.getOuuid() + " 分单服务 " + s, e);
        Jsp_ExceptionOrder zxpExceptionOrder = new Jsp_ExceptionOrder(state, jspOrder, exMessage);
        this.save(zxpExceptionOrder);
    }


}
